package Day01_Reflect;

import TestClass.Person;

import java.lang.reflect.Method;

public class Demo04_Reflect {
    public static void main(String[] args) throws Exception {
        /*Class cls = Person.class;
        Method[] methods = cls.getMethods();
        for (Method m : methods
             ) {
            System.out.println(m);
        }*/
        Class cls = Person.class;
        Method makelove = cls.getMethod("makelove", String.class);
        Person p = new Person();
        //执行方法
        makelove.invoke(p, "黄旭婷");
        System.out.println("--------------------");
        Method[] methods = cls.getMethods();
        for (Method m : methods
        ) {
            System.out.println(m.getName());
        }
    }
}